<%@include file="aaa.jsp"%>

<%    
    String query = "select from " + Item.class.getName() +  " where owner!='"+ user.getEmail() +"'";
    List<Item> items = (List<Item>) pm.newQuery(query).execute();

    if (items.isEmpty()) {
%>
	<p>Your friends have no items for borrowing.</p>
<%
    } else {
%>		
<table class='list'>
<%
		int alternate = 0;
        for (Item i : items) {
			++alternate;
%> 
					<tr class='<% if(alternate%2==0){%>item-odd<%}else{%>item-pair<%}%>'
						onmouseover='this.className="item-over";'
						onmouseout='this.className="<% if(alternate%2==0){%>item-odd<%}else{%>item-pair<%}%>";'>
						<td class='item-title'>
							<%= i.getTitle() %>
						</td>
						<td class='item-ico'>
							<img class='ico' src='
							<% if (i.getType().equals("DVD")) {%>
							img/dvd.png
							<%} else if(i.getType().equals("CD")) {%>
							img/cd.png
							<%} else if(i.getType().equals("Book")) {%>
							img/book.png
							<%}%>
							' />
						</td>
						<td class='item-type'>
							<%= i.getType() %>
						</td>
						<td class='item-empty'>
						</td>
					    <td class='item-request'>
					       <form action="/borrowItem" method="post" >
					    	<input type="hidden" value="<%= i.getItemID().getId() %>" name="itemID" />
					        <input class='request' type="submit" value="Request Borrowing" <% if(i.isReserved()){ %> disabled="disabled" <% } %>/>
					       </form>
					    </td>
					</tr>        

<%
        }
    }
    pm.close();
%>
</table>